package top.wangjiu.java.jvm.attribute;

import top.wangjiu.java.jvm.AttributeInfo;
import top.wangjiu.java.jvm.attribute.info.InnerClassesInfo;
import top.wangjiu.java.jvm.constantinfo.ConstantPoolInfo;

/**
 * 该属性用于记录内部类和宿主类之间的关系。如果一个类中定义了内部类，编译器将会为这个类与这个类包含的内部类生成InnerClasses属性
 */
public class InnerClassesAttr extends AttributeInfo {

    public final static String NAME = "InnerClasses";

    private final short attributeNameIndex;   //属性名索引
    private final int attributeLength;
    private final short numberOfClasses;
    private final InnerClassesInfo[] innerClasses;

    public InnerClassesAttr(short attributeNameIndex,int attributeLength,InnerClassesInfo[] innerClasses){
        this.attributeNameIndex = attributeNameIndex;
        this.attributeLength = attributeLength;
        this.numberOfClasses = (short) innerClasses.length;
        this.innerClasses = innerClasses;
    }

    @Override
    public short attributeNameIndex() {
        return attributeNameIndex;
    }

    @Override
    public int attributeLength() {
        return attributeLength;
    }

    @Override
    public String toString(ConstantPoolInfo[] poolInfos) {
        return null;
    }
}
